<?php

declare(strict_types=1);

namespace app\model\system;

use owns\interface\OwnsModelInteface;

class UserGroupModel extends OwnsModelInteface
{
    protected $name = 'system_user_group';

    protected $field = [];

    /**
     * 查询条件
     * @param object $query
     * @param array $param
     */
    public function scopeCustom(object $query, array $param)
    {
        // 名称
        if($name = $param['name'] ?? '') {
            $query->whereLike('name', '%'.trim($name).'%');
        }
        // 负责人
        if($leader = $param['leader'] ?? '') {
            $query->whereLike('leader', '%'.trim($leader).'%');
        }
        // 联系电话
        if($phone = $param['phone'] ?? '') {
            $query->whereLike('phone', '%'.trim($phone).'%');
        }
    }
}
